home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-ARM / BYTEORDE.{_H < prev    next >
Text File  |  1999-09-17  |  1KB  |  52 lines

  1. #ifndef __ASM_ARM_BYTEORDER_H
  2. #define __ASM_ARM_BYTEORDER_H
  3.  
  4. #include <asm/types.h>
  5.  
  6. #if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 8
  7.  
  8. /* Recent versions of GCC can open code the swaps at least as well
  9.    as we can write them by hand, so the "optimisations" here only 
  10.    make sense for older compilers.  Worse, some versions of GCC
  11.    actually go wrong in the presence of the assembler versions.
  12.    We play it safe and only turn them on for compilers older than
  13.    GCC 2.8.0.  */
  14.  
  15. static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
  16. {
  17.     unsigned long xx;
  18.     __asm__("eor\t%1, %0, %0, ror #16\n\t"
  19.         "bic\t%1, %1, #0xff0000\n\t"
  20.         "mov\t%0, %0, ror #8\n\t"
  21.         "eor\t%0, %0, %1, lsr #8\n\t"
  22.         : "=r" (x), "=&r" (xx)
  23.         : "0" (x));
  24.     return x;
  25. }
  26.  
  27. static __inline__ __const__ __u16 ___arch__swab16(__u16 x)
  28. {
  29.     __asm__("eor\t%0, %0, %0, lsr #8\n\t"
  30.         "eor\t%0, %0, %0, lsl #8\n\t"
  31.         "bic\t%0, %0, #0xff0000\n\t"
  32.         "eor\t%0, %0, %0, lsr #8\n\t"
  33.         : "=r" (x) 
  34.         : "0" (x));
  35.     return x;
  36. }
  37.  
  38. #define __arch__swab32(x) ___arch__swab32(x)
  39. #define __arch__swab16(x) ___arch__swab16(x)
  40.  
  41. #endif /* __GNUC__ */
  42.  
  43. #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  44. #  define __BYTEORDER_HAS_U64__
  45. #  define __SWAB_64_THRU_32__
  46. #endif
  47.  
  48. #include <linux/byteorder/little_endian.h>
  49.  
  50. #endif
  51.  
  52.